import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export function createRouter(cookies) {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/login',
        name: 'Login',
        component: () => import(/* webpackChunkName:"login" */'@/pages/Login.vue')
      },
      {
        path: '',
        name: 'Layout',
        component: () => import(/* webpackChunkName:"layout" */'@/layout/Layout.vue'),
        redirect: '/',
        children: [
          {
            path: '/',
            name: 'Home',
            component: () => import(/* webpackChunkName:"home" */'@/pages/Home.vue')
          },
          {
            path: '/about',
            name: 'About',
            component: () => import(/* webpackChunkName:"about" */'@/pages/About.vue')
          },
          {
            path: '/article',
            name: 'Article',
            meta: {
              requireAuth: true
            },
            component: () => import(/* webpackChunkName:"article" */'@/pages/Article.vue')
          },
        ]
      },
      {
        path: '*',
        name: 'Errors',
        component: () => import(/* webpackChunkName:"errors" */'@/pages/Errors.vue')
      }
    ]
  })
}